
// Chong, Huang & Wu, 2021, JJPS //
// Corresponding Author: Wen-Chin Wu, wenchinwu@sinica.edu.tw //

clear all
set scheme cleanplots 

////////////////////////////////////////////////////////////////////////////////
// Note: The data used in this study is a merged dataset based on the survey //
//       results of the Taiwan National Security Survey (Waves 2016, 2019, and //
//       2020). For operationalization of variables in this merged dataset, // 
//       please refer to the appendix of the published article or contact the //
//       corresponding author. 
////////////////////////////////////////////////////////////////////////////////


use CHW_2022_JJPS_Replication.dta, replace

// Figure 1 //

tab type4, gen(type4_dum)

gen t1 = type4_dum1*100
gen t2 = type4_dum2*100
gen t3 = type4_dum3*100
gen t4 = type4_dum4*100

collapse t1 t2 t3 t4 [pw=w], by(year)

reshape long t, i(year) j(bar)

lab def bar 1 "Isolation" 2 "Bandwagon" ///
            3 "Balance" 4 "Hedge"

lab val bar bar
		
			
graph bar t, over(year) over(bar, ///
      relabel(1 "Isolation" ///
	          2 "Bandwagon" ///
              3 "Balance" ///
			  4 "Hedge"))  ///
	  bargap(30) blabel(bar, position(outside) ///
	  format(%9.2f) size(small))  scheme(plotplain) ///
	  ytitle("Proportion of Respondents (%)") ///
	  bar(1, color(ebblue))


// Figure 2: Hostility //

use CHW_2022_JJPS_Replication.dta, replace

tab ecocoercion4, gen(ecocoercion4_dum)

gen dum1 = ecocoercion4_dum1*100
gen dum2 = ecocoercion4_dum2*100
gen dum3 = ecocoercion4_dum3*100
gen dum4 = ecocoercion4_dum4*100


graph bar dum1-dum4, over(year) stack ///
      scheme(cleanplots) legend(position(6) ///
	  order(1 "Strongly Disagree" 2 "Disagree" ///
	        3 "Agree" 4 "Strongly Agree") row(1)) ///
	  bar(1, bcolor(red)) bar(2, bcolor(red*0.5)) ///
	  bar(3, bcolor(ebblue*0.5)) bar(4, bcolor(ebblue)) ///
	  ylabel(0(25)100) ytitle("Proportion of Respondents (%)") ///
	  yline(50, lpattern(dash) lcolor(black)) ///
	  blabel(bar, format(%9.2f) position(center))
	  
// Figure 3: Hostility  //

use CHW_2022_JJPS_Replication.dta, replace

statsby mean=r(mean) ub=r(ub) lb=r(lb) N= r(N), by(year) clear: ci mean hostility

gen x = .
replace x = 1 if year == 2016
replace x = 2 if year == 2019
replace x = 3 if year == 2020

format mean %9.2f

twoway bar mean x, color(ebblue) barw(0.5)  ||  ///
       rcap ub lb x, lcolor(red) ||  ///
	   scatter mean x, ms(none) mlabel(mean) mlabcolor(red) mlabposition(2)  ///
	   scheme(plotplain) ///
	   xscale(range(0.6 3)) ///
	   xlabel(1 "2016" 2 "2019" 3 "2020") ///
	   ylabel(0(1)7, format(%9.0f)) ytitle("Perceived Hostility") ///
	   legend(off) xtitle("Year")


// Figure 4: Marginal Effects of Economic Coercion  //

use CHW_2022_JJPS_Replication.dta, replace

recode year (2016 = 1)(2019 = 2)(2020 = 3), gen(wave)

forval i = 1/3 {

mlogit type4 age age2 male college ///
      i.pid4 i.tondu3 ///
	  i.identity3 ///
	  defense_ind capacity ///
  	  c.hostility##c.hostility   ///
	  ecocoercion4  ///
	  if wave == `i',base(4) nolog rrr
	  
margins, at(ecocoercion4 = (1(1)4))
marginsplot, scheme(cleanplots) legend(position(6) row(2) ///
			 order(5 "Isolation" 6 "Bandwagon" ///
			       7 "Balance"  8 "Hedge")) ///
			ylabel(0(0.15)0.9, format(%9.2f)) ///
			title("")  ytitle("")

graph save g`i'.gph, replace
}

graph combine g1.gph g2.gph g3.gph, ycommon row(1) ///
      l1title("Predicted Probability") 

// Figure 5: Marginal Effects of Perceived Hostility  //
		
forval i = 1/3 {

mlogit type4 age age2 male college ///
      i.pid4 i.tondu3 ///
	  i.identity3 ///
	  defense_ind capacity ///
  	  c.hostility##c.hostility   ///
	  ecocoercion4  ///
	  if wave == `i',base(4) nolog rrr
	  		
margins, at(hostility = (0(1)10))
marginsplot, scheme(cleanplots) legend(position(6) row(2) ///
			 order(5 "Isolation" 6 "Bandwagon" ///
			       7 "Balance"  8 "Hedge")) ///
			ylabel(0(0.15)0.75, format(%9.2f)) ///
			title("")  ytitle("") xtitle("Perceived Hostility")

graph save g`i'.gph, replace
}

graph combine g1.gph g2.gph g3.gph, ycommon row(1) ///
      l1title("Predicted Probability") 

	  
// Table 3 //

// 2016 //

mlogit type4 age age2 male college ///
      i.pid4 i.tondu3 ///
	  i.identity3 ///
	  defense_ind capacity ///
  	  c.hostility##c.hostility   ///
	  ecocoercion4  ///
	  if year == 2016,base(4) nolog rrr

// 2019 //

mlogit type4 age age2 male college ///
      i.pid4 i.tondu3 ///
	  i.identity3 ///
	  defense_ind capacity ///
  	  c.hostility##c.hostility   ///
	  ecocoercion4  ///
	  if year == 2019,base(4) nolog rrr

// 2020 //

mlogit type4 age age2 male college ///
      i.pid4 i.tondu3 ///
	  i.identity3 ///
	  defense_ind capacity ///
  	  c.hostility##c.hostility   ///
	  ecocoercion4  ///
	  if year == 2020,base(4) nolog rrr

// Table 4 //

mlogit type4 age age2 male college ///
      i.pid4 i.tondu3 ///
	  i.identity3 ///
	  defense_ind  capacity ///
      ecocoercion4  ///
	  c.hostility##c.hostility /// 
	  hk, ////
	  base(4) nolog rrr

// Online Appendix: Party ID // 

mlogit type4 age age2 male college ///
      i.partyid i.tondu3 ///
	  i.identity3 ///
	  defense_ind capacity ///
  	  c.hostility##c.hostility   ///
	  ecocoercion4  ///
	  if year == 2016,base(4) nolog rrr

estadd fitstat

eststo mlogit2016_pid


mlogit type4 age age2 male college ///
      i.partyid i.tondu3 ///
	  i.identity3 ///
	  defense_ind capacity ///
	  c.hostility##c.hostility ///
	  ecocoercion4  ///
	  if year == 2019,base(4) nolog rrr

mlogit type4 age age2 male college ///
      i.partyid i.tondu3 ///
	  i.identity3 ///
	  defense_ind capacity ///
	  c.hostility##c.hostility ///
	  ecocoercion4  ///
	  if year == 2020,base(4) nolog rrr


/////////////////////
// End of Do File //
////////////////////
